﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;

namespace EP2_Gameserver
{
    public static class Data
    {

        public static DataTable SpawnList = new DataTable();

        public static float[] CurrentPos_X = new float[1000000];
        public static float[] CurrentPos_Z = new float[1000000];
        public static ArrayList[] SpawnedIndex = new ArrayList[1000000];

        public static void GetNPCSpawnList()
        {
            LogScreen.Info("Loading Spawnlist..");

            string[] results = mySQL.PerformQuery("SELECT a_npc_idx, a_zone_num, a_pos_x, a_pos_z, a_pos_h, a_pos_r, a_index FROM t_npc_regen WHERE a_zone_num = 0");
            int count = results.Count() / 7;

            
            SpawnList.Columns.Add("NPC" , typeof(int));
            SpawnList.Columns.Add("Zone" , typeof(int));
            SpawnList.Columns.Add("X" , typeof(float));
            SpawnList.Columns.Add("Z" , typeof(float));
            SpawnList.Columns.Add("H" , typeof(float));
            SpawnList.Columns.Add("R" , typeof(float));
            SpawnList.Columns.Add("ID", typeof(int));

            int b = 0;
            for (int a = 1; a <= count; a++)
            {
                SpawnList.Rows.Add
                    (
                        Convert.ToInt32(results[b]),   // NPC
                        Convert.ToInt32(results[(b + 1)]), // Zone
                        Convert.ToSingle(results[(b + 2)]), // X
                        Convert.ToSingle(results[(b + 3)]), // Z
                        Convert.ToSingle(results[(b + 4)]), // H
                        Convert.ToSingle(results[(b + 5)]), // R
                        Convert.ToInt32(results[(b + 6)])  // ID
                    );

                b = b + 7;

            }

            LogScreen.Info("Zone 0 : " + count.ToString() + " SpawnPoints Loaded");


        }
    }
}
